/**
 * @file video.h
 * Video defines, macros and typedefs
 *
 * Description of video.h
 *
 * @addtogroup video libellen video handlers
 * @{
 *
 */

#ifndef __VIDEO_H__
#define __VIDEO_H__
		
#include <nds/memory.h>
#include <nds/arm9/video.h>
		
// ----------------- Defines	-----------------
		
/**
 * The gap between the two screens in pixels
 */
#define SCREEN_GAP				(64 + 16)
		
/**
 * Width of hardware tile
 */
#define HW_TILE_WIDTH			(8)
/**
 * Height of hardware tile
 */
#define HW_TILE_HEIGHT			(8)
		
/**
 * Number of palettes available per color mode
 */
#define LN_PAL_COUNT			(16)
/**
 * Number of colors in a color mode
 */
#define COLMODE_COLCOUNT(c) 	(1 << (4 << (c)))
		
/**
 * Size of 16col tile in bytes
 */
#define SIZEOF_TILE_16			(HW_TILE_WIDTH * HW_TILE_HEIGHT / 2)
/**
 * Size of 256col tile in bytes
 */
#define SIZEOF_TILE_256			(HW_TILE_WIDTH * HW_TILE_HEIGHT)
/**
 * Size of a tile in bytes for colormode
 */
#define SIZEOF_TILE_COLMODE(c)	((HW_TILE_WIDTH * HW_TILE_HEIGHT) >> (!(c)))
		
/**
 * Size of a single palette color in a palette in bytes
 */
#define PALETTE_BPP				(sizeof(u16))
/**
 * Size of a palette for color mode in bytes
 */
#define SIZEOF_PAL_COLMODE(c)	(COLMODE_COLCOUNT(c) * PALETTE_BPP)
/**
 * Size of a 16col palette
 */
#define SIZEOF_PAL_16			(SIZEOF_PAL_COLMODE(COLMODE_16))
/**
 * Size of a 256col palette
 */
#define SIZEOF_PAL_256			(SIZEOF_PAL_COLMODE(COLMODE_256))
		
#define BG_EXTPAL_MAIN			VRAM_E
#define BG_EXTPAL_SUB			VRAM_H
#define OBJ_EXTPAL_MAIN			VRAM_G
#define OBJ_EXTPAL_SUB			VRAM_I
		
// ----------------- Types		-----------------
		
/**
 * Screen selection type
 *
 * @note As useless as LN_SCREEN_COUNT looks, it's being used in the internal structure on many types for faster code
 */
typedef enum
{
	SCREEN_MAIN,		/**< Main Screen */
	SCREEN_SUB,			/**< Sub Screen */
		
	LN_SCREEN_COUNT,	/**< Number of screens */
		
} lntScreen;
		
/**
 * Tile color mode
 */
typedef enum
{
	COLMODE_16,			/**< 16 colors */
	COLMODE_256,		/**< 256 colors */
		
} lntColMode;
		
/**
 * Priority for sprites and backgrounds
 */
typedef enum
{
	PRIORITY_HIGHEST,	/**< Highest priority */
	PRIORITY_HIGH,		/**< High priority */
	PRIORITY_NORMAL,	/**< Normal priority */
	PRIORITY_LOW,		/**< Low priority */
		
} lntPriority;
		
/**
 * A point on a 2D space
 */
typedef union tPoint2D
{
	tPoint2D(int x = 0, int y = 0):
		X(x), Y(y) { }
		
	struct {
		int X; /**< X position */
		int Y; /**< Y position */
	};
		
	struct {
		int x; /**< X position (alt case) */
		int y; /**< Y position (alt case) */
	};
		
} tPoint2D, *pPoint2D;
		
#endif
		
/**
 * @}
 */
